<template>
	<view>
		<cu-custom bgColor="bg-blue" isBack>
			<block slot="content">打包数据统计</block>
		</cu-custom>

		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-title text-blue"></text>30天内打包统计
			</view>
		</view>
		<view class="grid col-2 bg-white padding-sm">
			<view class="padding-sm" v-for="(item,index) in lists" :key="index">
				<view class="padding radius text-center light bg-cyan">
					<view class="text-lg">日期：{{item.day}}</view>
					<view class="margin-top-sm text-Abc text-red">合计：{{item.total}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lists:[]
			}
		},
		methods: {
				//SELECT  scanTime , substr(datetime(scanTime/1000,'unixepoch'),0,12)  as day ,COUNT(substr(datetime(scanTime/1000,'unixepoch'),0,12)) FROM express  GROUP BY day
				getData(){
					plus.sqlite.selectSql({
						name: 'express',
						// sql: 'select * from express where  type = "box" and status = 1 LIMIT 2 ORDER BY scanTime DESC;',
						//1584264443480
						//1584288000000
						//sql: 'select * from express where  type = "box" and status = 1 and scanTime > ' + this.nowTime +  " ORDER BY scanTime DESC",
						sql:"SELECT  scanTime , substr(datetime(scanTime/1000,'unixepoch'),0,12)  as day ,COUNT(substr(datetime(scanTime/1000,'unixepoch'),0,12)) as total FROM express WHERE type = 'box'  GROUP BY day ORDER BY day desc LIMIT 30",
						success: (data) => {
							console.log('selectSql success: ');
							this.lists = data
							console.log(JSON.stringify(data));
						},
						fail: function(e) {
							console.log('selectSql failed: ' + JSON.stringify(e));
						}
					});
				}
		},
		onShow() {
			this.getData()
		}
	}
</script>

<style>

</style>
